package com.monas.server.transfer;

import com.monas.server.MonasException;
import com.monas.server.MonasProperties;
import com.monas.server.database.MonasDatabase;

public class MonasTransfer {

	public void transfer() {

		// TODO : create multi thread / process for faster transfer
		// get all server
		for (String server : MonasProperties.getAllServer()) {
			// transfer
			MonasTransferClient client = null;
			try {
				client = new MonasTransferClient(server);
				client.getFiles();
			} catch (MonasException e) {
				System.out.println(e.getMessage());
			} finally {
				if (client != null) {
					client.disconnect();
				}
			}
		}

	}

	public static void main(String[] args) {

		MonasDatabase database = MonasDatabase.getInstance();

		try {
			MonasTransfer transfer = new MonasTransfer();
			transfer.transfer();
		} finally {
			database.close();
		}
	}
}
